package com.itHuangTao.tank.introduce;

import com.almasb.fxgl.app.scene.FXGLMenu;
import com.almasb.fxgl.app.scene.MenuType;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.texture.Texture;
import com.itHuangTao.tank.ui.HelpMenu;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

public class Level extends FXGLMenu {
    public Level() {
        super(MenuType.GAME_MENU);
        //设置背景图
        Texture texture = FXGL.texture("background.png");
        Text text1 = new Text(
                "简单起步\n" +
                        "关卡1：初次相见\n" +
                        "关卡2：热血街头\n" +
                        "关卡3：黑暗丛林\n" +
                        "关卡4：岛屿奇兵");
        Text text2 = new Text(
                "挑战上升\n" +
                        "关卡5：未知恐惧\n" +
                        "关卡6：护城战争\n" +
                        "关卡7：石门庄\n" +
                        "关卡8：决战威尼斯");
        text1.setFill(Color.RED);
        text1.setFont(new Font("微软雅黑", 26));
        text2.setFill(Color.RED);
        text2.setFont(new Font("微软雅黑", 26));

        StackPane pane1 = new StackPane(texture);
        //设置窗口大小
        pane1.setPrefSize(FXGL.getAppWidth(), FXGL.getAppHeight());
        //设置背景色(黑色)
        pane1.setStyle("-fx-background-color: black");

        StackPane pane2 = new StackPane(text1);
        //设置窗口大小
        pane2.setPrefSize(300, 300);
        pane2.setTranslateX(50);
        pane2.setTranslateY(200);
        StackPane pane3 = new StackPane(text2);
        //设置窗口大小
        pane3.setPrefSize(300, 300);
        pane3.setTranslateX(500);
        pane3.setTranslateY(200);

        //按钮属性
        Button btnReturnLastMenu = new Button("返回上一级");
        btnReturnLastMenu.getStyleClass().add("menu-btn");//利用css设置样式
        btnReturnLastMenu.setOnAction(event -> {
            FXGL.getSceneService().pushSubScene(new HelpMenu());
        });
        //存放按钮属性
        VBox box = new VBox(30, btnReturnLastMenu);
        box.setLayoutX(FXGL.getAppWidth() / 2.0 - 50);
        box.setLayoutY(450);
        getContentRoot().getChildren().addAll(pane1, pane2, pane3, box);
    }
}
